package com.zhuojy.equity.mall.admin.web.controller;

import com.zhuojy.equity.mall.admin.common.entity.TAuditCenter;

import com.zhuojy.equity.mall.admin.common.entity.po.THolidayPo;
import com.zhuojy.equity.mall.admin.common.entity.vo.AuditCenterExportEntity;
import com.zhuojy.equity.mall.admin.common.entity.vo.BalanceVO;
import com.zhuojy.equity.mall.admin.common.pojo.JsonResult;
import com.zhuojy.equity.mall.admin.service.AuditCenterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author:LYL
 * @Date 2024/3/19 9:06
 * 审批中心controller
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("auditCenter")
@Api(tags = "审批模块")
public class AuditCenterController {
    @Autowired
    private AuditCenterService auditCenterService;

    //待处理
    @ApiOperation(value = "审批列表，分页查询", httpMethod = "POST", notes = "审批列表分页查询")
    @RequestMapping("findTAuditCenterPaginationList")
    public JsonResult findTAuditCenterPaginationList(@RequestBody TAuditCenter tAuditCenter, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return auditCenterService.findTAuditCenterPaginationList(tAuditCenter, pageNum, pageSize);
    }

    //已处理
    @ApiOperation(value = "审批列表，分页查询", httpMethod = "POST", notes = "审批列表分页查询")
    @RequestMapping("findTAuditCenterPaginationList2")
    public JsonResult findTAuditCenterPaginationList2(@RequestBody TAuditCenter tAuditCenter, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        System.out.println(tAuditCenter.getApprover());
        return auditCenterService.findTAuditCenterPaginationList2(tAuditCenter, pageNum, pageSize);
    }

    //我收到的
    @ApiOperation(value = "审批列表，分页查询", httpMethod = "POST", notes = "审批列表分页查询")
    @RequestMapping("findTAuditCenterPaginationList3")
    public JsonResult findTAuditCenterPaginationList3(@RequestBody TAuditCenter tAuditCenter, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        System.out.println(tAuditCenter.getApprover());
        return auditCenterService.findTAuditCenterPaginationList3(tAuditCenter, pageNum, pageSize);
    }

    //我发起的
    @ApiOperation(value = "审批列表，分页查询", httpMethod = "POST", notes = "审批列表分页查询")
    @RequestMapping("findTAuditCenterPaginationList4")
    public JsonResult findTAuditCenterPaginationList4(@RequestBody TAuditCenter tAuditCenter, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return auditCenterService.findTAuditCenterPaginationList4(tAuditCenter, pageNum, pageSize);
    }

    @ApiOperation(value = "审批列表回显，回显", httpMethod = "POST", notes = "审批列表回显")
    @RequestMapping("findTAuditCenterById")
    public TAuditCenter findTAuditCenterById(Long id) {
        return auditCenterService.findTAuditCenterById(id);
    }

    @ApiOperation(value = "审批列表修改状态，修改状态", httpMethod = "POST", notes = "审批列表修改状态")
    @RequestMapping("updateStatusById")
    public JsonResult updateStatusById(@RequestBody TAuditCenter tAuditCenter) {
        try {
            auditCenterService.updateStatusById(tAuditCenter);
            return JsonResult.success(200, "修改成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "修改失败！");
        }
    }
    @ApiOperation(value = "审批列表修改状态，修改状态", httpMethod = "POST", notes = "审批列表修改状态")
    @RequestMapping("updateApprovalStatusById")
    public JsonResult updateApprovalStatusById(@RequestBody TAuditCenter tAuditCenter) {
        try {
            auditCenterService.updateApprovalStatusById(tAuditCenter);
            return JsonResult.success(200, "修改成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "修改失败！");
        }
    }


    @ApiOperation(value = "审批列表添加，添加", httpMethod = "POST", notes = "审批列表添加")
    @RequestMapping("insertTAuditCenter")
    public JsonResult insertTAuditCenter(@RequestBody TAuditCenter tAuditCenter) {
        try {
            auditCenterService.insertTAuditCenter(tAuditCenter);
            return JsonResult.success(200, "添加成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "添加失败！");
        }
    }

    //请假记录表条查分页
    @ApiOperation(value = "请假记录表条查分页", httpMethod = "POST", notes = "请假记录表条查分页")
    @RequestMapping("findTAuditPagination")
    public JsonResult findTAuditPagination(@RequestBody AuditCenterExportEntity auditCenterExportEntity, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        System.out.println(auditCenterExportEntity);
        return auditCenterService.findTAuditPagination(auditCenterExportEntity, pageNum, pageSize);
    }

    //请假记录表删除
    @ApiOperation(value = "请假记录表批量删除", httpMethod = "POST", notes = "请假记录表批量删除")
    @RequestMapping("deleteTAuditByIds")
    public JsonResult deleteTAuditByIds(Integer id) {
        try {
            auditCenterService.deleteTAuditByIds(id);
            return JsonResult.success(200, "批量删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "批量删除失败");
        }
    }
    //请假记录表多表导出
    @ApiOperation(value = "请假记录表多表导出", httpMethod = "POST", notes = "请假记录表多表导出")
    @RequestMapping(value = "/export/excel", produces = MediaType.APPLICATION_JSON_VALUE)
    public boolean exportExcel(HttpServletResponse response) {
        auditCenterService.exportExcel(response);
        return true;
    }

    //请假记录表条查动态下拉列表
    @ApiOperation(value = "请假记录表条查动态下拉列表", httpMethod = "POST", notes = "请假记录表条查动态下拉列表")
    @RequestMapping("findOptions")
    public List<TAuditCenter> findOptions() {
        return auditCenterService.findOptions();
    }

    //员工假期余额表条查分页
    @ApiOperation(value = "员工假期余额表条查分页", httpMethod = "POST", notes = "员工假期余额表条查分页")
    @RequestMapping("findbalancePagination")
    public JsonResult findbalancePagination(@RequestBody TAuditCenter tAuditCenter, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return auditCenterService.findbalancePagination(tAuditCenter, pageNum, pageSize);
    }

    //员工余额表多表导出
    @ApiOperation(value = "员工余额表多表导出", httpMethod = "POST", notes = "员工余额表多表导出")
    @RequestMapping(value = "/exportblance/excel", produces = MediaType.APPLICATION_JSON_VALUE)
    public boolean exportblanceExcel(HttpServletResponse response) {
        auditCenterService.exportblanceExcel(response);
        return true;
    }
    //员工余额表回显
    @ApiOperation(value = "员工余额表回显", httpMethod = "POST", notes = "员工余额表回显")
    @RequestMapping(value = "findBalanceById")
    public BalanceVO findBalanceById(Integer id){
        return auditCenterService.findBalanceById(id);
    }
    //员工余额表修改
    @ApiOperation(value = "员工余额表修改", httpMethod = "POST", notes = "员工余额表修改")
    @RequestMapping(value = "updateBalance")
    public JsonResult updateBalance(@RequestBody BalanceVO balanceVO){
        try {
            auditCenterService.updateBalance(balanceVO);
            return JsonResult.success(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444,"修改失败");
        }
    }
    @ApiOperation(value = "审批用户表多表导出", httpMethod = "POST", notes = "审批用户表多表导出")
    @RequestMapping(value = "/getAuditCenterEntity", produces = MediaType.APPLICATION_JSON_VALUE)
    public boolean getAuditCenterEntity(HttpServletResponse response){
        auditCenterService.getAuditCenterEntity(response);
        return true;
    }
}
